Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

C Programming Interviews Questions


Bit and Bytes

Q.1 What is a bit?

Answer: A bit is the smallest unit of data in computing, representing a binary digit, either 0 or 1.

Q.2 What is a byte?

Answer: A byte is a unit of digital information comprising 8 bits.

Q.3 How many bits are there in a byte?

Answer: There are 8 bits in a byte.

Q.4 Explain the concept of bitwise AND (&) operator.

Answer: Bitwise AND (&) operator performs a bitwise AND operation on each pair of corresponding bits. The result is 1 only if both bits are 1, otherwise 0.

Q.5 What is the difference between bitwise AND (&) and logical AND (&&) operators?

Answer: Bitwise AND (&) is a binary operator that performs bitwise AND operation on individual bits, while logical AND (&&) is a logical operator that returns true if both operands are true.

Q.6 Describe the concept of bitwise OR (|) operator.

Answer: Bitwise OR (|) operator performs a bitwise OR operation on each pair of corresponding bits. The result is 1 if at least one of the bits is 1.

Q.7 How does the bitwise XOR (^) operator work?

Answer: Bitwise XOR (^) operator performs a bitwise XOR operation on each pair of corresponding bits. The result is 1 if the bits are different, otherwise 0.

Q.8 Explain the bitwise NOT (~) operator.

Answer: Bitwise NOT (~) operator performs a bitwise negation operation, flipping each bit from 0 to 1 and vice versa.

Q.9 What is a bitmask?

Answer: A bitmask is a binary pattern used for bitwise operations to manipulate or extract specific bits in a binary value.

Q.10 How can you set a specific bit in a variable to 1?

Answer: You can use the bitwise OR (|) operator with a bitmask to set a specific bit to 1.

Q.11 How can you clear a specific bit in a variable?

Answer: You can use the bitwise AND (&) operator with the complement of a bitmask to clear a specific bit.

Q.12 Explain left shift (<<) and right shift (>>) bitwise operators.

Answer: Left shift (<<) operator shifts the bits of a number to the left by a specified number of positions, while right shift (>>) operator shifts the bits to the right.

Q.13 How can you check if a particular bit is set in a variable?

Answer: You can use bitwise AND (&) operator with a bitmask to check if a specific bit is set.

Q.14 What is a signed integer?

Answer: A signed integer is a data type that can represent positive, negative, or zero values, using one bit for sign representation (usually in two's complement form).

Q.15 What is an unsigned integer?

Answer: An unsigned integer is a data type that represents only non-negative numbers, starting from zero.

Q.16 How do you represent negative numbers in binary using two's complement?

Answer: To represent negative numbers in binary using two's complement, invert all bits of the positive binary number and add 1.

Q.17 What is the largest value an 8-bit unsigned integer can hold?

Answer: The largest value an 8-bit unsigned integer can hold is 255 (2^8 - 1).

Q.18 Explain the concept of endianness in computer architecture.

Answer: Endianness refers to the byte ordering used to store multibyte data types in memory. It can be either little-endian (least significant byte first) or big-endian (most significant byte first).

Q.19 How do you convert a little-endian byte order to big-endian and vice versa?

Answer: To convert from little-endian to big-endian, reverse the byte order. Vice versa for converting from big-endian to little-endian.

Q.20 What are the benefits of using bitwise operations in programming?

Answer: Bitwise operations provide efficient ways to manipulate individual bits or groups of bits within variables, which is useful for tasks such as setting flags, packing data, and performing optimizations.




Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML 5

Python

java

C++

C

JavaScript

Campus Learning

C

C#

java